package com.pro.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;

import com.pro.entity.BannerEntity;
import com.pro.entity.DesignerEntity;
import com.pro.util.DBManager;
import com.pro.util.QueryResult;

public class DesignerDaoImpl {
	//查询设计师
	public ArrayList<DesignerEntity> designerAll(){
		ArrayList<DesignerEntity> dEntity= new ArrayList<DesignerEntity>();
	    String sqlString="select id,create_time,img,name,position from designer";
	    QueryResult rSet=DBManager.executeQuery(sqlString);
	      if (rSet!=null) {
	        try {
	          while (rSet.rs.next()) {
	        	  dEntity.add(new DesignerEntity(rSet.rs.getInt("id"),
	            		rSet.rs.getString("create_time"),
	            		rSet.rs.getString("img"),
	            		rSet.rs.getString("name"),
	            		rSet.rs.getString("position")));
	            		
	          }
	        } catch (SQLException e) {
	          e.printStackTrace();
	        }
	      }
	      rSet.close();
	    return dEntity;
	}
    //修改
	public int designerUpdate(DesignerEntity dEntity) {
 		String sqlString="update designer set create_time='"+dEntity.getCreateTime()+"',img='"+dEntity.getImg()+"',name='"+dEntity.getName()+"',position='"+dEntity.getPosition()+"' where id = '"+dEntity.getId()+"'";
 		 int result= DBManager.executeUpdate(sqlString);
 		return result;
 	}
	//添加
	 public int designerAdd(DesignerEntity dEntity) {
 		String sqlString="insert into designer(create_time,img,name,position) values('"+dEntity.getCreateTime()+"','"+dEntity.getImg()+"','"+dEntity.getName()+"','"+dEntity.getPosition()+"')";
 		 int result= DBManager.executeUpdate(sqlString);
 		return result;
 	}
	 //删除
	 public int designerDelete(int id) {
			// TODO Auto-generated method stub
			String sqlString = "delete from designer where id = '"+id+"'";
			int result = DBManager.executeUpdate(sqlString);
			return result;
		}

}
